package com.example.myblog.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*
    配置类
 */
@Configuration
public class AppConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())//添加拦截器
                .addPathPatterns("/**")//监控资源
                .excludePathPatterns("/css/**")//放行资源
                .excludePathPatterns("/editor.md/**")
                .excludePathPatterns("/img/**")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/login.html")
                .excludePathPatterns("/reg.html")
                .excludePathPatterns("/blog_list.html")
                .excludePathPatterns("/blog_content.html")
                .excludePathPatterns("/article/detail")
                .excludePathPatterns("/article/incr-rcount")
                .excludePathPatterns("/article/listbypage")
                .excludePathPatterns("/user/getuserbyid")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/user/register")
                .excludePathPatterns("/user/getTextCode")
                .excludePathPatterns("/user/getImageCode")
                .excludePathPatterns("/user/update")
                .excludePathPatterns("/user/uploadphoto");
    }
}
